<?php
namespace app\common\logic;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
//发送邮件操作
class MailLogic{
	static function sendEmailMsg($data=[]){
		$to = $data['to'];//发送给谁
		$mail = new PHPMailer();
		$mail->isSMTP();  //使用smtp鉴权方式发送邮件
		$mail->CharSet = 'utf8';   //设置编码
		$mail->Host = $data['mail_smtp_host'];  //qq邮箱smtp邮箱
		$mail->SMTPAuth = true;    //是否需要认证身份
		$mail->Username = $data['mail_smtp_user'];  //发送方邮箱
		$mail->Password = $data['mail_smtp_pass'];    //发送方smtp密码
		$mail->SMTPSecure = $data['mail_secure'];    //使用的协议
		$mail->Port = $data['mail_smtp_port'];   //qq邮箱接收的端口号
		$mail->setFrom($data['mail_smtp_user'], $data['mail_smtp_name']);  //定义邮件及标题
		$mail->addAddress($to, '收件人');  //要发送的地址和设置地址的昵称
		$mail->addReplyTo($data['mail_smtp_user'], '回复'); //回复地址
		$mail->Subject = $data['subject'];  //添加该邮件的主题
		$mail->Body = $data['content']; //该邮件内容
		return $mail->send();
	} 
}